package com.px.service;

import com.px.client.DxUserFeignClient;
import com.px.dto.ReturnResult;
import com.px.dto.ReturnResultUtils;
import com.px.pojo.ShUser;
import com.px.utils.MD5Utils;
import com.px.vo.UserVo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class DxUserServiceImpl implements DxUserService {
    @Resource
    private DxUserFeignClient dxUserFeignClient;

    /**
     * 添加手机号
     * @param shUser
     * @return
     * @throws Exception
     */
    @Override
    public ReturnResult tj(UserVo shUser) throws Exception {
      ShUser user = new ShUser();
      //获取用户
        user.setAccount(shUser.getAccount());
        //获取密码并加密
        String password = MD5Utils.getMd5(shUser.getPassword(), 32);
        //添加密码
        user.setPassword(password);
        //调用方法
        boolean dxtj = dxUserFeignClient.dxtj(user);
        if (dxtj){
            return ReturnResultUtils.returnSuccess();
        }
        return ReturnResultUtils.returnFail(10023,"错误");

    }

    /**
     * 查找手机号
     * @param account
     * @return
     * @throws Exception
     */
    @Override
    public ShUser cz(String account) throws Exception {
        return dxUserFeignClient.czyh(account);
    }
}
